package com.imooc.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.imooc.dataobject.OrderDetail;
import com.imooc.enums.OrderStatusEnum;
import com.imooc.enums.PayStatusEnum;
import com.imooc.util.EnumUtil;
import com.imooc.util.serializer.DateSerializer;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author liuhuan
 * @date 2018/7/7 09:21
 * @description
 */
@Data
public class OrderDTO {
    /**
     * id
     */

    private String orderId;
    /**
     * 买家名字
     */
    private String buyerName ;
    /**
     * 买家电话
     */
    private String buyerPhone;
    /**
     *买家地址
     */
    private String buyerAddress ;
    /**
     *买家微信号openid
     */
    private String buyerOpenId ;
    /**
     *订单金额
     */
    private BigDecimal orderAmount ;
    /**
     *订单状态
     */
    private Integer orderStatus;
    /**
     *支付状态
     */
    private Integer  payStatus;

    /**
     * 创建时间
     */
    @JsonSerialize(using = DateSerializer.class)
    private Date createTime;
    /**
     * 修改时间
     */
    @JsonSerialize(using = DateSerializer.class)
    private Date updateTime;

    /**
     * 订单详情
     */
    private List<OrderDetail> orderDetailList;

    @JsonIgnore
    public OrderStatusEnum getOrderStatusEnum(){
        return EnumUtil.getByCode(orderStatus,OrderStatusEnum.class);
    }
    @JsonIgnore
    public PayStatusEnum getPayStatusEnum(){
        return EnumUtil.getByCode(payStatus,PayStatusEnum.class);
    }
}
